package com.xieyunjie.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;

/**
 * @program: 0812springboot
 * @author: 雷哥
 * @create: 2019-12-16 11:35
 **/
//@Aspect
//@Component
//@EnableAspectJAutoProxy  //这个可以不加
public class ManAspect {


    //声明切面
    public static final String POINTCUT1="execution(* com.xieyunjie.domain.Man.eat(..))";

//    @Pointcut(POINTCUT1)
//    public void mycut(){
//
//    }
//

    //@Before(POINTCUT1)
    public void before(){
        System.out.println("饭前喝汤");
    }
    //@After(POINTCUT1)
    public void after(){
        System.out.println("搞一根");
    }

   // @Around(POINTCUT1)
    public  void around(ProceedingJoinPoint pjp) throws Throwable {
        before();
        pjp.proceed();
        after();
    }

    @AfterThrowing(value = POINTCUT1,throwing = "tw")
    public void exp(Throwable tw){
        System.out.println("出现异常:"+tw.getMessage());
    }

}
